#include "Map.h"

Map::Map():	 _bitmap(getDefaultBitmap(SAND_BITMAP))
{

}
Movable_type Map::positionType(Point position) const
{
	return _screen_map.at(position.x()).at(position.y());
}


void Map::plotMovable(Movable_type type, const Point& location, int radius)
{
	int x_pos = location.x();
	int y_pos = location.y();

	for(int i = -radius; i <= radius; i++)
	{
		for(int j = -radius; j <= radius; j++)
		{
			_screen_map.at(x_pos + i).at(y_pos + j) = type;		
		}
	}
}

void Map::removeAllMovables()
{
	for(int i = 0; i != GAME_GRID_ELEMENTS; i++)
	{
		for(int j = 0; j != GAME_GRID_ELEMENTS; j++)
		{
			if(_screen_map.at(i).at(j) != HOLE && 	_screen_map.at(i).at(j) !=SAND)
				_screen_map.at(i).at(j) = HOLE;
		}
	}
}

void Map::removeMovable(const Point& location, int radius)
{
	int x_pos = location.x();
	int y_pos = location.y();
	
	for(int i = -radius; i <= radius; i++)
	{
		for(int j = -radius; j <= radius; j++)
		{
			_screen_map.at(x_pos + i).at(y_pos + j) = HOLE;		
		}
	}
}

void Map::set(vector<vector <Movable_type>> mp)
{
	 _screen_map = mp;
}

vector<vector <Movable_type>> Map::elements()
{
	return _screen_map;
}

ALLEGRO_BITMAP *Map::bitmap()
{
	return _bitmap;
}